<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8"/>
    <title>商品管理</title>
    <meta name="keywords" content="">
    <meta name="description" content="">
    <meta name="renderer" content="webkit">
    <meta http-equiv="Cache-Control" content="no-siteapp"/>
    <meta name="mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="format-detection" content="telephone=no,email=no,address=no"/>
    <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no">
    <link rel="stylesheet" href="../css/common.css"/>
    <link rel="stylesheet" href="../css/main.css"/>
</head>
<body class="goods_manager">
    <article>
        <section class="tabBar">
            <div class=" flex lh90 tac col9 bw tab">
                <div class="flex1 active item" data-status="1">出售中</div>
                <div class="flex1 item" data-status="0">仓库中</div>
            </div>
            <div class="h10 bgf5"></div>
        </section>
        <section class="container pb130">
            <ul class="goods">
                <!--<li class="plr24 bw goods_item">-->
                    <!--<div class="ptb30 bdb flex_a">-->
                        <!--<div>-->
                            <!--<img src="../img/test.png" class="goods_pic">-->
                        <!--</div>-->
                        <!--<div class="flex1 ml20">-->
                            <!--<p class="font15">清风纸巾</p>-->
                            <!--<p class="mt10 color2">￥2.00</p>-->
                        <!--</div>-->
                    <!--</div>-->
                    <!--<div class="flex jce">-->
                        <!--<a class="flex_a col9 ptb30">-->
                            <!--<img src="../img/ico8.png" style="width:.3rem;">-->
                            <!--<span class="ml10">编辑</span>-->
                        <!--</a>-->
                        <!--<div class="flex_a col9 ml40 ptb30">-->
                            <!--<img src="../img/ico9.png" style="width:.3rem;">-->
                            <!--<span class="ml10">下架</span>-->
                        <!--</div>-->
                        <!--<div class="flex_a col9 ml40 ptb30">-->
                            <!--<img src="../img/ico10.png" style="width:.3rem;">-->
                            <!--<span class="ml10">删除</span>-->
                        <!--</div>-->
                    <!--</div>-->
                <!--</li>-->
            </ul>
        </section>
        <footer class="ptb20 pos_f bottom0 pw100 bgf5">
            <div class="plr30">
                <button class="border-r6 bgc1 colw tac lh90 pw100 btn_tap">添加商品</button>
            </div>
        </footer>
    </article>
</body>
</html>
<script src="../js/jquery-1.8.3.min.js"></script>
<script src="../js/dlc.js"></script>
<script>
   $('.btn_tap').click(function(){
       location.href = './supply_add_goods.html';
   });
   var status = 1;
   $('.tab').on('click','.item',function(){
       $(this).addClass('active').siblings().removeClass('active');
       status = $(this).data('status');
       get_list();
   });
   get_list();
   function get_list(){
       dlctipbox.loading();
       dlc_request('/api/goods/goodsList',{'status':status,'page':1,'limit':999}, function(res){
           console.log(res);
           if(res.code==1){
               var res = res.data.list;
               var str = '';
               for(var i in res){
                   str+='<li class="plr24 bw goods_item">'+
                           '<div class="ptb30 bdb flex_a">'+
                           '<div>'+
                           '<img src="'+dlcUrl()+res[i].imgUrl+'" class="goods_pic">'+
                           '</div>'+
                           '<div class="flex1 ml20">'+
                           '<p class="font15">'+res[i].name+'</p>'+
                           '<p class="mt10 color2">￥'+res[i].price+'</p>'+
                   '</div>'+
                   '</div>'+
                   '<div class="flex jce">'+
                           '<a href="./supply_add_goods.html?id='+res[i].id+'" class="flex_a col9 ptb30">'+
                           '<img src="../img/ico8.png" style="width:.3rem;">'+
                           '<span class="ml10">编辑</span>'+
                           '</a>'+
                           '<div class="flex_a col9 ml40 ptb30 '+(res[i].status==1?"down":"up")+'" data-id="'+res[i].id+'">'+
                           '<img src="../img/ico9.png" style="width:.3rem;">'+
                           '<span class="ml10">'+(res[i].status==1?"下架":"上架")+'</span>'+
                           '</div>'+
                           '<div class="flex_a col9 ml40 ptb30 delete" data-id="'+res[i].id+'">'+
                           '<img src="../img/ico10.png" style="width:.3rem;">'+
                           '<span class="ml10">删除</span>'+
                           '</div>'+
                           '</div>'+
                           '</li>';
               }
               if(str){
                   $('.goods').html(str);
               }else{
                   $('.goods').html(emptyTip('暂无商品'));
               }
               dlctipbox.clear();
           }else{
               dlctipbox.show(res.msg);
           }
       });
   }
    $('.goods').on('click','.down',function(){
        var that = this;
        dlctipbox.confirm('是否下架？',function(index){
           if(index == 1){
               dlc_request('/api/goods/changeGoodsToDown',{'id':$(that).data('id'),'status':0}, function(res){
                   console.log(res);
                   if(res.code == 1){
                       get_list();
                   }
                   dlctipbox.show(res.msg);
               });
           }
        });
    });
   $('.goods').on('click','.up',function(){
       var that = this;
       dlctipbox.confirm('是否上架？',function(index){
           if(index == 1){
               dlc_request('/api/goods/changeGoodsToDown',{'id':$(that).data('id'),'status':1}, function(res){
                   console.log(res);
                   if(res.code == 1){
                       get_list();
                   }
                   dlctipbox.show(res.msg);
               });
           }
       });
   });
   $('.goods').on('click','.delete',function(){
       var that = this;
       dlctipbox.confirm('是否删除？',function(index){
           if(index == 1){
               dlc_request('/api/goods/deleteGoodsById',{'id':$(that).data('id')}, function(res){
                   console.log(res);
                   if(res.code == 1){
                       get_list();
                   }
                   dlctipbox.show(res.msg);
               });
           }
       });
   });
</script>






















